package cf;

import java.util.*;

public class CpuSuanLiFenPei {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[m];
        int[] b = new int[n];
        int sum = 0;
        int sumA = 0;
        HashSet<Integer> set = new HashSet<>();

        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
            sumA += a[i];
            sum += a[i];
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
            sum += b[i];
            set.add(b[i]);
        }
        Arrays.sort(a);
        sum /= 2;
        for (int i = 0; i < m; i++) {
            if (set.contains(Integer.valueOf(sum+a[i]-sumA))) {
                System.out.print(a[i]);
                System.out.print(" ");
                System.out.println(sum+a[i]-sumA);
                break;
            }
        }

    }
}
